package com.zhs.gccs.http;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.PartMap;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

public interface ApiService {
    //@Path  @Query
    @POST("hcAppLogin")
    Observable<String> hcAppLogin(@Body RequestBody body);//登录

    @POST("hcAppLogin2")
    Observable<String> hcAppLogin2(@Body RequestBody body);//不需要绑定设备登录


    @POST("deviceBind")
    Observable<String> deviceBind(@Body RequestBody body);


    @POST("appLatestVersion2")
    Observable<String> appLatestVersion2(@Body RequestBody body);

    @GET("getInfo")
    Observable<String> getUserInfo();//
    //系统用户相关
    @GET("system/user/list/role/{roleKey}")
    Observable<String> getUserListByRoleKey(@Path("roleKey") String roleKey);


    //获取字典
    @GET("gccj/dicts")
    Observable<String> getGccjDictsList();

    //下载文件
    @Streaming
    @GET("common/download/bypath")
    Call<ResponseBody> downloadFileByPath(@Query("fileName") String fileName);

    @GET("system/code/obtainCode")
    Observable<String> getVerifyCode(@Query("phoneNumber") String phoneNumber);

    @GET
    Observable<String> getOther(@Url String url);


    @Multipart
    @POST("task/feedback/uploader/file")
    Call<ResponseBody> uploadFeedbackFile(@PartMap Map<String, RequestBody> params,
                                          @Part MultipartBody.Part file);

    @POST("task/feedback/uploader/confirm")
    Call<ResponseBody> uploadFileConfirm(@Body RequestBody body);//登录

    @GET("system/xzq/list/all")
    Observable<String> xzqList();
//    @POST("check/task/apply/{userPhone}")
//    Observable<String> applyTask(@Path("userPhone") String userPhone, @Body RequestBody body);

    @POST("check/task/createByCc")
    Observable<String> applyTask(@Body RequestBody body);

    @POST("todo/apply/history/list")
    Observable<String> applyTaskHistoryList(@Query("pageSize") int pageSize,
            @Query("pageNum") int pageNum,
            @Body RequestBody body);
    //////////////////////////////////////////////////////
    @POST("project/app/query/list/all")
    Observable<String> projectQueryAll(@Body RequestBody body);

    @POST("project/app/query/list")
    Observable<String> projectQuery(@Query("pageSize") int pageSize,
                                       @Query("pageNum") int pageNum,
                                       @Body RequestBody body);

    @GET("task/project/list/{taskId}")
    Observable<String> getTaskProjectList(@Path("taskId") String taskId);
    //////////////////////////////////////////////////////
    @GET("todo/task/list/{taskState}")
    Observable<String> todoApplyTask(@Path("taskState") String taskState,
            @Query("pageSize") int pageSize,
            @Query("pageNum") int pageNum);

    @GET("todo/apply/device/list")
    Observable<String> todoApplyDevice(@Query("pageSize") int pageSize,
                                     @Query("pageNum") int pageNum);


    @POST("check/task/applyTaskByCc")
    Observable<String> auditApplyTask(@Body RequestBody body);
    //任务申请驳回
    @POST("check/task/applyTaskByCc")
    Observable<String> returnApplyTask(@Body RequestBody body);



    @POST("todo/task/list")
    Observable<String> taskTodoList(@Query("pageSize") int pageSize,
                                     @Query("pageNum") int pageNum,
                                    @Body RequestBody body
    );

    //终止任务
    @GET("check/task/cancel/{userPhone}/{taskId}")
    Observable<String> cancelTask(@Path("userPhone") String userPhone,
                                      @Path("taskId") String taskId);


    @POST("admin/bind/user/device/{userId}")
    Observable<String> auditApplyDevice(@Path("userId") Long userId);
    //////////////////////////////////////////////////////
    //综合查询
    @POST("gt/statistics")
    Observable<String> queryGtGb(@Body RequestBody body);
    @GET("gt/areas")
    Observable<String> queryGtAreas();
    @GET("gt/gb/dicts")
    Observable<String> queryGbDicts();

    @GET("system/dict/data/type/gb")
    Observable<String> queryGbProps();
    @GET("system/dict/data/type/gtlx")
    Observable<String> queryGtTypes();
    //////////////////////////////////////////////////////

    @GET("cadatamgt/get/project/data/{taskId}/{pid}")
    Observable<String> getTaskProjectGccjDataInfo(@Path("taskId") String taskId,
                                                  @Path("pid") String pid);
    @POST("cadatamgt/save/project/data")
    Observable<String> saveTaskProjectGccjData(@Body RequestBody body);
    //获取字典列表及统计
    @POST("cadatamgt/list/caDict/statistics")
    Observable<String> taskProjectGccjMenuDataList(@Body RequestBody body);

    //获取数据列表
    @POST("cadatamgt/list/caDict/form/datas")
    Observable<String> taskProjectGccjDataList(@Body RequestBody body);

    //获取表单配置及详情 如果没有传数据id，就是获取页面字典配置
    @POST("cadatamgt/get/caDict/form/details")
    Observable<String> taskProjectGccjDataForm(@Body RequestBody body);

    @POST("cadatamgt/get/caDict/form/details/{dataId}")
    Observable<String> taskProjectGccjDataFormById(@Path("dataId") String dataId);




    @POST("cadatamgt/save/caData/form")
    Observable<String> taskProjectGccjSaveData(@Body RequestBody body);

    @POST("cadatamgt/save/caData/form/file/{dataId}")
    Observable<String> taskProjectGccjSaveDataFile(@Path("dataId") String dataId,
                                                   @Body RequestBody body);

    @POST("cadatamgt/caData/form/deleteFile")
    Observable<String> taskProjectGccjDataDeleteFile(@Body RequestBody body);

    @POST("cadatamgt/caData/form/deleteData")
    Observable<String> taskProjectGccjDataDeleteData(@Body RequestBody body);

    //加载图层数据
    @POST("cadatamgt/caData/layerData")
    Observable<String> taskProjectGccjLayerData(@Body RequestBody body);


    //保存轨迹
    @POST("cadatamgt/caData/gj/sync")
    Observable<String> taskGjSyncToServer(@Body RequestBody body);

    @POST("cadatamgt/caData/gj/sync/toapp/{taskId}")
    Observable<String> taskGjSyncFromServer(@Path("taskId") String taskId);

    @POST("cadatamgt/caData/gj/sync/toapp/{taskId}/{gjId}")
    Observable<String> taskGjSyncFromServer(@Path("taskId") String taskId,
                                            @Path("gjId") String gjId);

    //工程抽检文件上传
    //https://blog.51cto.com/u_16213671/7853070
    /**
     * private void toSaveGccjData(String filePath,HashMap<String,String> params) {
     *         File file = new File(filePath);
     *         if (!file.exists()) {
     *             Log.e("xp", "file = " + file.getAbsolutePath());
     *         }
     *         String contentType   = "multipart/form-data";
     *         RequestBody requestFile = RequestBody.create(MediaType.parse(contentType), file);
     *         RequestBodyUpload requestBodyUpload = new RequestBodyUpload(requestFile, file.getName(), new CommonCallback.OnProgressWithNameCallBack() {
     *             @Override
     *             public void onProgress(String filename, float percent) {
     *                 Log.e("xp", "filename = " + filename + ", percent = " + percent);
     *             }
     *         });
     *         MultipartBody.Part fileBody = MultipartBody.Part.
     *                 createFormData("file", file.getName(), requestBodyUpload);
     *         //构造参数
     *         Map<String, RequestBody> _params = new HashMap<>();
     *         Iterator<Map.Entry<String, String>> iterator = params.entrySet().iterator();
     *         while (iterator.hasNext()) {
     *             Map.Entry<String, String> entry = iterator.next();
     *             RequestBody requestBody = RequestBody.
     *                     create(MediaType.parse(contentType),
     *                     entry.getValue());
     *             _params.put(entry.getKey(), requestBody);
     *         }
     *         toSubscribeSingleOb(Api.getDefault()
     *                         .gccjUploadFile(_params, fileBody),
     *                 new ProgressObserver(this, false) {
     *                     @Override
     *                     protected void _onNext(String result) {
     *                         ProjectGccjLevelDataBean bean = JSON.parseObject(result, ProjectGccjLevelDataBean.class);//GsonImpl.get().toObject(result, SmTaskBean.class);
     *                         if (bean != null && bean.getCode() == 200
     *                                 && bean.getRows() != null && bean.getRows().size() > 0) {
     *
     *                         } else {
     *                         }
     *                     }
     *
     *                     @Override
     *                     protected void _onError(String result) {
     *                     }
     *                 });
     *     }
     * @param params
     * @param file
     * @return
     */
    @Multipart
    @POST("caDataMgt/caFile/upload/file")
    Observable<String> gccjUploadFile(
            @PartMap Map<String, RequestBody> params,
            @Part MultipartBody.Part file);
    @Multipart
    @POST("caDataMgt/caFile/upload/files")
    Observable<String> gccjUploadFiles(
            @PartMap Map<String, RequestBody> params,
            @Part List<MultipartBody.Part> files);
    //////////////////////////////////////////////////////

    @POST("cadatamgt/save/caData/form/file/{dataId}")
    Observable<String> gccsSaveDataFile(@Path("dataId") String dataId,
                                                   @Body RequestBody body);
    @Multipart
    @POST("gccsFile/upload/files")
    Observable<String> gccsUploadFiles(
            @PartMap Map<String, RequestBody> params,
            @Part List<MultipartBody.Part> files);


    @GET("/hcApi/gccsAdmin/xmStatistics")
    Observable<String> queryTaskStatistics();

    @GET("/hcApi/gccsAdmin/xmList")
    Observable<String> queryTaskxmList();

    @GET("/hcApi/gccsAdmin/xmList2")
    Observable<String> queryTaskxmList(@Query("pXianCode") String pXianCode,
                                                  @Query("pyear") String pyear,
                                                  @Query("pageSize") int pageSize,
                                                  @Query("pageNum") int pageNum);

    @GET("/hcApi/gccsAdmin/getXzq2")
    Observable<String> getGccsXmXzq();

    @POST("/hcApi/GccsTaskSsgh/saveProjectSsgh")
    Observable<String> saveGccsExtform(@Body RequestBody body);
    @GET("/hcApi/GccsTaskSsgh/{pid}")
    Observable<String> getGccsExtForm(@Path("pid") String pid);

    @POST("/hcApi/gccsAdmin/saveGccsTask")
    Observable<String> saveGccsTask(@Body RequestBody body);
    @PUT("/hcApi/gccsExec/updateGccsTaskState")
    Observable<String> updateGccsTaskState(@Body RequestBody body);

    @POST("/hcApi/gccsExec/saveGccsform")
    Observable<String> saveGccsform(@Body RequestBody body);

    @POST("/hcApi/gccsExec/saveGccsFile")
    Observable<String> saveGccsFile(@Body RequestBody body);

    @POST("/hcApi/gccsExec/deleteGccsFile")
    Observable<String> deleteGccsformFile(@Body RequestBody body);

    @GET("/hcApi/gccsAdmin/getCjUsers")
    Observable<String> getCjUsers();

    @POST("/hcApi/gccsAdmin/deleteGccsUser")
    Observable<String> deleteGccsUser(@Body RequestBody body);
    @POST("/hcApi/gccsAdmin/stopGccsUser")
    Observable<String> stopGccsUser(@Body RequestBody body);
    @POST("/hcApi/gccsAdmin/startGccsUser")
    Observable<String> startGccsUser(@Body RequestBody body);
    @POST("/hcApi/gccsAdmin/saveGccsUser")
    Observable<String> saveGccsUser(@Body RequestBody body);




    @GET("/hcApi/gccs/dictList")
    Observable<String> gccsDictList();

    @GET("/hcApi/gccs/types")
    Observable<String> getGccsTypes();


    @GET("/hcApi/gccs/types/statistics/{pid}")
    Observable<String> getXmGccsStatistics(@Path("pid") String pid);

    @GET("/hcApi/gccsExec/xmList")
    Observable<String> gccsExecList(@Query("pageSize") int pageSize,
                                    @Query("pageNum") int pageNum);
    @POST("/hcApi/gccsExec/deleteGccsData")
    Observable<String> gccsDeleteData(@Body RequestBody body);

    @GET("/hcApi/gccsExec/xmGccsList")
    Observable<String> xmGccsList(@Query("pid") String pid,
                                   @Query("gccsType") String gccsType,
                                    @Query("qualified") String qualified,
                                    @Query("pageSize") int pageSize,
                                    @Query("pageNum") int pageNum);

    @GET("/hcApi/gccsExec/xmGccsDataInfo/{id}")
    Observable<String> xmGccsInfo(@Path("id") String id);


    @Multipart
    @POST("/hcApi/gccsFile/upload/file")
    Observable<String> gccsUploadFile(
            @PartMap Map<String, RequestBody> params,
            @Part List<MultipartBody.Part> files);



    //////////////////////////////////////////////////////
}
